package com.shangyitong.yygh_hosp.controller;

import com.shangyitong.Result;
import com.shangyitong.yygh.model.hosp.Hospital;
import com.shangyitong.yygh.vo.hosp.HospitalQueryVo;
import com.shangyitong.yygh_hosp.service.HospitalRearService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Optional;

@RestController
@Slf4j
@RequestMapping("/admin/hosp/hospital")
public class HospitalRearController {

    @Autowired
    private HospitalRearService hospitalRearService;

    /**
     * 医院列表接口
     * finished
     * @param page
     * @param limit
     * @param hospitalQueryVo
     * @return
     */
    @ApiOperation("医院列表接口")
    @GetMapping("list/{page}/{limit}")
    public Result showHospitalList(@PathVariable Integer page,
                                   @PathVariable Integer limit,
                                   HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> hospitalList = hospitalRearService.showHospitalList(page, limit, hospitalQueryVo);
        return Result.ok(hospitalList);
    }

    /**
     * 查看医院详细
     * finished
     * @param id
     * @return
     */
    @ApiOperation(value = "查看医院详细")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        Map<String, Object> mapHospital = hospitalRearService.showHospDetail(id);
        return Result.ok(mapHospital);
    }
    /**
     * 跟新医院上线状态
     * finished
     * @param id
     * @param status
     * @return
     */
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id,
                                   @PathVariable Integer status) {
        hospitalRearService.updateHospStatus(id, status);
        return Result.ok();
    }
}
